<template>
    <div class="new-graph file-info">
        <pui-dialog :maskClick="false" :title="props.title" v-model="componentRef.dialogVisible" :animate="props.animate" isFooter @onCancel="closeDialog">
            <template #content>
                <div class="form">
                    <div class="form-item">
                        <div class="label">器件名称</div>
                        <pui-input placeholder="请输入器件名称" v-model="componentRef.name" type="input" clearAble full></pui-input>
                    </div>
                </div>
            </template>
            <template #footer>
                <pui-button @click="addCompo">确认</pui-button>
            </template>
        </pui-dialog>
    </div>
</template>
<script lang="ts">
import { defineComponent } from 'vue'
export default defineComponent({
    name: 'NewGraph'
})
</script>
<script lang="ts" setup>
import { reactive, getCurrentInstance, watch } from 'vue'
const props = defineProps({
    title: {
        type: String,
        default: '添加器件'
    },
    animate: {
        type: String,
        default: 'fade'
    }
})
const emit = defineEmits({
    onClose: (val: any) => {},
    onSubmit: (val: any) => {}
})
const componentRef = reactive({
    dialogVisible: false,
    name: '',
    sourceType: ''
})
const init = (type: any) => {
    componentRef.sourceType = type
    componentRef.dialogVisible = true
}
const closeDialog = () => {
    componentRef.dialogVisible = false
    emit('onClose', '关闭')
}
const addCompo = () => {
    emit('onSubmit', {name: componentRef.name, type: componentRef.sourceType})
    closeDialog()
}
defineExpose({
    init
})
</script>
<style lang="scss">
@import '../fileControl/fileStyle.scss';
</style>